package com.sthz.facepay.mapper;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO;
import static org.apache.ibatis.jdbc.SqlBuilder.SET;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;
import static org.apache.ibatis.jdbc.SqlBuilder.UPDATE;
import static org.apache.ibatis.jdbc.SqlBuilder.VALUES;
import static org.apache.ibatis.jdbc.SqlBuilder.WHERE;

import com.sthz.facepay.model.Merchant;

public class MerchantSqlProvider {

    public String insertSelective(Merchant record) {
        BEGIN();
        INSERT_INTO("st_merchant");
        
        if (record.getId() != null) {
            VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getName() != null) {
            VALUES("name", "#{name,jdbcType=VARCHAR}");
        }
        
        if (record.getContacts() != null) {
            VALUES("contacts", "#{contacts,jdbcType=VARCHAR}");
        }
        
        if (record.getPhone() != null) {
            VALUES("phone", "#{phone,jdbcType=VARCHAR}");
        }
        
        if (record.getData_time() != null) {
            VALUES("data_time", "#{data_time,jdbcType=DATE}");
        }
        
        if (record.getPay_type() != null) {
            VALUES("pay_type", "#{pay_type,jdbcType=TINYINT}");
        }
        
        if (record.getBusiness_abbreviation() != null) {
            VALUES("business_abbreviation", "#{business_abbreviation,jdbcType=VARCHAR}");
        }
        
        if (record.getShop_type() != null) {
            VALUES("shop_type", "#{shop_type,jdbcType=TINYINT}");
        }
        
        if (record.getAddress() != null) {
            VALUES("address", "#{address,jdbcType=VARCHAR}");
        }
        
        if (record.getService_phone() != null) {
            VALUES("service_phone", "#{service_phone,jdbcType=VARCHAR}");
        }
        
        if (record.getWeixin_appid() != null) {
            VALUES("weixin_appid", "#{weixin_appid,jdbcType=VARCHAR}");
        }
        
        if (record.getResponsible_person() != null) {
            VALUES("responsible_person", "#{responsible_person,jdbcType=VARCHAR}");
        }
        
        if (record.getContact() != null) {
            VALUES("contact", "#{contact,jdbcType=VARCHAR}");
        }
        
        if (record.getEmail() != null) {
            VALUES("email", "#{email,jdbcType=VARCHAR}");
        }
        
        if (record.getCardholder() != null) {
            VALUES("cardholder", "#{cardholder,jdbcType=VARCHAR}");
        }
        
        if (record.getCash_bank() != null) {
            VALUES("cash_bank", "#{cash_bank,jdbcType=VARCHAR}");
        }
        
        if (record.getBank_number() != null) {
            VALUES("bank_number", "#{bank_number,jdbcType=VARCHAR}");
        }
        
        if (record.getCard_picture() != null) {
            VALUES("card_picture", "#{card_picture,jdbcType=VARCHAR}");
        }
        
        return SQL();
    }

    public String updateByPrimaryKeySelective(Merchant record) {
        BEGIN();
        UPDATE("st_merchant");
        
        if (record.getContacts() != null) {
            SET("contacts = #{contacts,jdbcType=VARCHAR}");
        }
        
        if (record.getPhone() != null) {
            SET("phone = #{phone,jdbcType=VARCHAR}");
        }
        
        if (record.getData_time() != null) {
            SET("data_time = #{data_time,jdbcType=DATE}");
        }
        
        if (record.getPay_type() != null) {
            SET("pay_type = #{pay_type,jdbcType=TINYINT}");
        }
        
        if (record.getBusiness_abbreviation() != null) {
            SET("business_abbreviation = #{business_abbreviation,jdbcType=VARCHAR}");
        }
        
        if (record.getShop_type() != null) {
            SET("shop_type = #{shop_type,jdbcType=TINYINT}");
        }
        
        if (record.getAddress() != null) {
            SET("address = #{address,jdbcType=VARCHAR}");
        }
        
        if (record.getService_phone() != null) {
            SET("service_phone = #{service_phone,jdbcType=VARCHAR}");
        }
        
        if (record.getWeixin_appid() != null) {
            SET("weixin_appid = #{weixin_appid,jdbcType=VARCHAR}");
        }
        
        if (record.getResponsible_person() != null) {
            SET("responsible_person = #{responsible_person,jdbcType=VARCHAR}");
        }
        
        if (record.getContact() != null) {
            SET("contact = #{contact,jdbcType=VARCHAR}");
        }
        
        if (record.getEmail() != null) {
            SET("email = #{email,jdbcType=VARCHAR}");
        }
        
        if (record.getCardholder() != null) {
            SET("cardholder = #{cardholder,jdbcType=VARCHAR}");
        }
        
        if (record.getCash_bank() != null) {
            SET("cash_bank = #{cash_bank,jdbcType=VARCHAR}");
        }
        
        if (record.getBank_number() != null) {
            SET("bank_number = #{bank_number,jdbcType=VARCHAR}");
        }
        
        if (record.getCard_picture() != null) {
            SET("card_picture = #{card_picture,jdbcType=VARCHAR}");
        }
        
        WHERE("id = #{id,jdbcType=INTEGER}");
        WHERE("name = #{name,jdbcType=VARCHAR}");
        
        return SQL();
    }
}